<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPages/AdminDefault.Master"
  AutoEventWireup="true" CodeBehind="NewsCategory.aspx.cs" Inherits="ITViet.Web.Admin.NewsCategoryPage" %>

<%@ Register Assembly="DevExpress.Web.ASPxEditors.v9.1, Version=9.1.4.0, Culture=neutral, PublicKeyToken=5377c8e3b72b4073"
  Namespace="DevExpress.Web.ASPxEditors" TagPrefix="dxe" %>
<%@ Register Assembly="DevExpress.Web.ASPxGridView.v9.1, Version=9.1.4.0, Culture=neutral, PublicKeyToken=5377c8e3b72b4073"
  Namespace="DevExpress.Web.ASPxGridView" TagPrefix="dxwgv" %>
<%@ Register Assembly="DevExpress.Web.v9.1, Version=9.1.4.0, Culture=neutral, PublicKeyToken=5377c8e3b72b4073"
  Namespace="DevExpress.Web.ASPxPopupControl" TagPrefix="dxpc" %>
<%@ Register Assembly="DevExpress.Web.v9.1, Version=9.1.4.0, Culture=neutral, PublicKeyToken=5377c8e3b72b4073"
  Namespace="DevExpress.Web.ASPxCallback" TagPrefix="dxcb" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
  <div style="padding-top: 10px;">
    <asp:XmlDataSource ID="xdsLanguage" runat="server" DataFile="~/App_Data/Status.xml"
      XPath="Items/LanguageDisplay/Status"></asp:XmlDataSource>
    <dxwgv:ASPxGridView ID="gvCategory" ClientInstanceName="gvCategory" runat="server"
      OnCustomCallback="gvCategory_CustomCallback" OnCustomJSProperties="gvCategory_CustomJSProperties"
      OnRowUpdating="gvCategory_RowUpdating" OnRowInserting="gvCategory_RowInserting"
      OnRowDeleting="gvCategory_RowDeleting" OnCommandButtonInitialize="gvCategory_CommandButtonInitialize"
      AutoGenerateColumns="False" KeyFieldName="Id" Width="100%" OnDataBound="gvCategory_DataBound">
      <SettingsBehavior AllowDragDrop="false" AllowSort="false" ConfirmDelete="True" />
      <Styles>
        <Header ImageSpacing="5px" SortingImageSpacing="5px">
        </Header>
      </Styles>
      <Images>
        <CollapsedButton Height="12px" Width="11px" />
        <DetailCollapsedButton Height="9px" Width="9px" />
        <HeaderFilter Height="18px" Width="18px" />
        <HeaderActiveFilter Height="18px" Width="18px" />
        <FilterRowButton Height="13px" Width="13px" />
        <CustomizationWindowClose Height="17px" Width="17px" />
        <PopupEditFormWindowClose Height="17px" Width="17px" />
        <FilterBuilderClose Height="17px" Width="17px" />
      </Images>
      <Columns>
        <dxwgv:GridViewCommandColumn Name="Command" ButtonType="Image" VisibleIndex="0" 
          Width="60px" Caption=" ">
          <EditButton Visible="True">
            <Image Url="~/images/edit.png" />
          </EditButton>
          <NewButton Visible="True">
            <Image Url="~/images/add.png" />
          </NewButton>
          <DeleteButton Visible="True">
            <Image Url="~/images/delete.png" />
          </DeleteButton>
          <CancelButton>
            <Image Url="~/images/undo.gif" />
          </CancelButton>
          <UpdateButton>
            <Image Url="~/images/save.png" />
          </UpdateButton>
          <HeaderStyle HorizontalAlign="Center" />
          <CellStyle Cursor="pointer">
          </CellStyle>
        </dxwgv:GridViewCommandColumn>
        <dxwgv:GridViewDataTextColumn Name="Locale" VisibleIndex="1" Width="60px">
          <EditFormSettings Visible="False" />
          <DataItemTemplate>
            <span style="cursor: pointer;" onclick="updateLocale('<%#Eval("Id") %>')">
              <asp:Label ID="Label1" runat="server" CssClass="LinkItem" Text="<%$Resources:Strings, UpdateLocale %>"></asp:Label>
            </span>
          </DataItemTemplate>
        </dxwgv:GridViewDataTextColumn>
        <dxwgv:GridViewDataColumn FieldName="Name" VisibleIndex="2" Caption="<%$Resources:Strings, Name %>">
        </dxwgv:GridViewDataColumn>
      </Columns>
      <StylesEditors>
        <ProgressBar Height="29px">
        </ProgressBar>
      </StylesEditors>
      <SettingsText ConfirmDelete="<%$Resources:Messages,ERR0006 %>" />
      <ClientSideEvents EndCallback="function(s,e){ongvCategory_EndCallback(s,e);}"></ClientSideEvents>
    </dxwgv:ASPxGridView>
  </div>
  <div>
    <dxpc:ASPxPopupControl ID="pcCategoryLocale" runat="server" ClientInstanceName="pcCategoryLocale"
      HeaderText="<%$ Resources:Strings, NewsCategory %>" PopupHorizontalAlign="WindowCenter"
      PopupVerticalAlign="WindowCenter" AllowDragging="True" CloseAction="CloseButton"
      Modal="True" Width="400px">
      <CloseButtonImage Width="17px" />
      <SizeGripImage Width="12px" />
      <ContentCollection>
        <dxpc:PopupControlContentControl ID="PopupControlContentControl1" runat="server">
          <div>
            <table width="100%">
              <tr>
                <td>
                  <dxe:ASPxLabel ID="lblErrorMsg" runat="server" ClientInstanceName="lblErrorMsg">
                  </dxe:ASPxLabel>
                  <asp:HiddenField ID="hfCategoryId" runat="server" />
                </td>
              </tr>
              <tr>
                <td>
                  <table width="100%">
                    <tr>
                      <td width="80px">
                        <asp:Literal ID="Literal1" runat="server" Text="<%$ Resources:Strings, Language %>"></asp:Literal>
                        :
                      </td>
                      <td>
                        <dxe:ASPxComboBox ID="cbxLanguage" SelectedIndex="0" runat="server" DataSourceID="xdsLanguage"
                          TextField="Value" ValueField="Id" ValueType="System.Int32" ClientInstanceName="cbxLanguage"
                          Width="200px">
                          <ButtonStyle Width="13px">
                          </ButtonStyle>
                          <ValidationSettings>
                            <ErrorImage Width="14px" />
                          </ValidationSettings>
                          <ClientSideEvents SelectedIndexChanged="function(s,e){oncbxLanguage_SelectedIndexChanged(s,e)}">
                          </ClientSideEvents>
                        </dxe:ASPxComboBox>
                      </td>
                    </tr>
                    <tr>
                      <td width="80px">
                        <asp:Literal ID="Literal3" runat="server" Text="<%$ Resources:Strings, Name %>"></asp:Literal>
                        :
                      </td>
                      <td>
                        <dxe:ASPxTextBox ID="txtName" runat="server" ClientInstanceName="txtName" Width="200px">
                        </dxe:ASPxTextBox>
                      </td>
                    </tr>
                    <tr>
                      <td>
                        <asp:Literal ID="Literal13" runat="server" Text="<%$ Resources:Strings, Note %>"></asp:Literal>
                        :
                      </td>
                      <td>
                        <dxe:ASPxMemo ID="mmNote" ClientInstanceName="mmNote" runat="server" Height="71px"
                          Width="200px">
                        </dxe:ASPxMemo>
                      </td>
                    </tr>
                    <tr>
                      <td>
                      </td>
                      <td style="padding-top: 5px">
                        <div style="float: left;">
                          <dxe:ASPxButton ID="btnSaveLocale" runat="server" Text="<%$ Resources:Strings, Save %>">
                            <ClientSideEvents Click="function(s, e) {
                                    saveLocale();
	                                  e.processOnServer = false;  }" />
                          </dxe:ASPxButton>
                        </div>
                        <div style="float: left; padding-left: 3px;">
                          <dxe:ASPxButton ID="btnCancel" runat="server" Text="<%$ Resources:Strings, Cancel %>">
                            <ClientSideEvents Click="function(s, e) {
                                    pcCategoryLocale.Hide();
                                    e.processOnServer = false;  }" />
                          </dxe:ASPxButton>
                        </div>
                      </td>
                    </tr>
                  </table>
                </td>
              </tr>
            </table>
          </div>
        </dxpc:PopupControlContentControl>
      </ContentCollection>
    </dxpc:ASPxPopupControl>
    <dxcb:ASPxCallback ID="cbxCallback" ClientInstanceName="cbxCallback" runat="server"
      OnCallback="cbxCallback_Callback">
      <ClientSideEvents CallbackComplete="function(s,e){cbxCallback_CallbackComplete(s,e);}" />
    </dxcb:ASPxCallback>
  </div>

  <script type="text/javascript">
    function saveLocale() {
      pcWaiting.Show();
      cbxCallback.SendCallback('Save');
    }
    function updateLocale(id) {
      document.getElementById('<%=hfCategoryId.ClientID %>').value = id;
      setTimeout("cbxCallback.SendCallback('Load')", 10);
    }

    function cbxCallback_CallbackComplete(s, e) {
      var para = e.parameter;
      pcWaiting.Hide();
      var results = e.result.split('|');
      if (para == 'Load') {
        if (results[0] == 'S') {
          txtName.SetText(results[1]);
          mmNote.SetText(results[2]);
          pcCategoryLocale.Show();
        }
      }
      else if (para == 'Save') {
        if (e.result == '') {
          alertMessage('<%=(string)GetGlobalResourceObject("Messages", "ERR0005") %>');
        }
        else {
          alertMessage(e.result);
        }
      }
    }

    function oncbxLanguage_SelectedIndexChanged(s, e) {
      pcWaiting.Show();
      setTimeout("cbxCallback.SendCallback('Load')", 10);
    }
    
    function ongvCategory_EndCallback(s, e) {
      var error = s.cpInnerError;
      if (error != '') {
        alertMessage(error);
        return;
      }
    }
 
  </script>

</asp:Content>
